home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Utilities / Other / upsd / ups_folder / part01.old < prev    next >
Encoding:
Internet Message Format  |  1991-05-01  |  17.8 KB

  1. From: art@pilikia.pegasus.com (Authur W. Neilson III)
  2. Newsgroups: comp.sources.misc
  3. Subject: v18i005:  upsd - UPS monitor daemon, Part01/01
  4. Message-ID: <1991Apr9.044203.8382@sparky.IMD.Sterling.COM>
  5. Date: 9 Apr 91 04:42:03 GMT
  6. Approved: kent@sparky.imd.sterling.com
  7. X-Checksum-Snefru: 93736b6d fe6ddccc 02693e2a a5e6707a
  8.  
  9. Submitted-by: Authur W. Neilson III <art@pilikia.pegasus.com>
  10. Posting-number: Volume 18, Issue 5
  11. Archive-name: upsd/part01
  12.  
  13. The UPS monitor daemon or "upsd"  watches the serial port connected to 
  14. an UPS and will perform an unattended shutdown of the system if the UPS 
  15. is on battery longer than a specified number of minutes.  Upsd needs to 
  16. watch a tty with modem control properties, and expects the UPS to raise 
  17. DCD when it switches to battery backup and drop DCD when it goes back to 
  18. online.  Upsd was developed and tested under ISC with the FAS 2.08 driver
  19. and an American Power Conversion SmartUPS 600, your milage may
  20. vary on other OSes and UPSes.
  21.  
  22. Art
  23. -----8<----- cut here -----8<----- cut here -----8<----- cut here -----8<-----
  24. #! /bin/sh
  25. # This is a shell archive.  Remove anything before this line, then unpack
  26. # it by saving it into a file and typing "sh file".  To overwrite existing
  27. # files, type "sh file -c".  You can also feed this as standard input via
  28. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  29. # will see the following message at the end:
  30. #        "End of archive 1 (of 1)."
  31. # Contents:  MANIFEST Makefile README common.h funcs.c main.c ups
  32. # Wrapped by root@pilikia on Sat Apr  6 21:22:27 1991
  33. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  34. if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  35.   echo shar: Will not clobber existing file \"'MANIFEST'\"
  36. else
  37. echo shar: Extracting \"'MANIFEST'\" \(422 characters\)
  38. sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
  39. X   File Name        Archive #    Description
  40. X-----------------------------------------------------------
  41. X MANIFEST                   1    This shipping list
  42. X Makefile                   1    Upsd makefile    
  43. X README                     1    Documentation
  44. X common.h                   1    Common program header
  45. X funcs.c                    1    Functions 
  46. X main.c                     1    Main program
  47. X ups                        1    Init.d startup script
  48. END_OF_FILE
  49. if test 422 -ne `wc -c <'MANIFEST'`; then
  50.     echo shar: \"'MANIFEST'\" unpacked with wrong size!
  51. fi
  52. # end of 'MANIFEST'
  53. fi
  54. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  55.   echo shar: Will not clobber existing file \"'Makefile'\"
  56. else
  57. echo shar: Extracting \"'Makefile'\" \(942 characters\)
  58. sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  59. X##
  60. X#    M a k e f i l e
  61. X#
  62. X#    makefile for UPS monitor daemon
  63. X#
  64. X#    Arthur W. Neilson III
  65. X#    art@pilikia.pegasus.com
  66. X#    Sat Mar 30 1991
  67. X#
  68. X
  69. XCC = cc
  70. XDEFS =
  71. XCFLAGS = -O $(DEFS)
  72. XCFILES = main.c funcs.c
  73. XOFILES = main.o funcs.o
  74. XHFILES = common.h
  75. XLIBES =
  76. XDESTDIR = /etc
  77. XINITDIR = /etc/init.d
  78. XRC2DIR = /etc/rc2.d
  79. XRC2NUM = 22
  80. X
  81. Xupsd: $(OFILES)
  82. X    $(CC) $(CFLAGS) $(OFILES) -o $@ $(LIBES)
  83. X    @strip $@
  84. X    @mcs -d $@
  85. X
  86. Xinstall: upsd
  87. X    cp upsd $(DESTDIR)/upsd
  88. X    chown root $(DESTDIR)/upsd
  89. X    chgrp sys $(DESTDIR)/upsd
  90. X    chmod 550 $(DESTDIR)/upsd
  91. X
  92. Xinstall_rc: install
  93. X    cp ups $(INITDIR)/ups
  94. X    chown root $(INITDIR)/ups
  95. X    chgrp sys $(INITDIR)/ups
  96. X    chmod 744 $(INITDIR)/ups
  97. X    ln $(INITDIR)/ups $(RC2DIR)/S$(RC2NUM)ups
  98. X
  99. Xindent:
  100. X    @for f in $(CFILES); do \
  101. X        indent $$f; \
  102. X    done
  103. X
  104. Xkit:
  105. X    makekit -m
  106. X
  107. Xclean:
  108. X    rm -f upsd core *.o *.BAK Part*
  109. X
  110. Xclobber: clean
  111. X    rm -f $(DESTDIR)/upsd $(INITDIR)/ups $(RC2DIR)/S$(RC2NUM)ups
  112. X
  113. X# dependencies
  114. Xmain.o:        main.c $(HFILES)
  115. Xfuncs.o:    funcs.c $(HFILES)
  116. END_OF_FILE
  117. if test 942 -ne `wc -c <'Makefile'`; then
  118.     echo shar: \"'Makefile'\" unpacked with wrong size!
  119. fi
  120. # end of 'Makefile'
  121. fi
  122. if test -f 'README' -a "${1}" != "-c" ; then 
  123.   echo shar: Will not clobber existing file \"'README'\"
  124. else
  125. echo shar: Extracting \"'README'\" \(3910 characters\)
  126. sed "s/^X//" >'README' <<'END_OF_FILE'
  127. X     Tue Apr 02 23:24:20 HST 1991    art@pilikia.pegasus.com        Pg. 1
  128. X
  129. X    INTRODUCTION
  130. X
  131. X    The UPS monitor daemon or "upsd"  watches the serial port
  132. X    connected to an UPS and will perform an unattended shutdown
  133. X    of the system if the UPS is on battery longer than a specified
  134. X    number of minutes.  Upsd needs to watch a tty with modem control
  135. X    properties, and expects the UPS to raise DCD when it switches
  136. X    to battery backup and drop DCD when it goes back to online.
  137. X    Upsd was developed and tested under ISC with the FAS 2.08 driver
  138. X    and an American Power Conversion SmartUPS 600, your milage may
  139. X    vary on other OSes and UPSes.
  140. X
  141. X    The C source was written for system V and hence will require 
  142. X    some work to get it working under BSD or other UNIXes, the
  143. X    program is built via the Makefile.  A number of configurable
  144. X    defaults are in common.h, you may want to hack that file before
  145. X    making upsd.  Although the program can be run manually from the
  146. X    command line, users will most likely want the program to start
  147. X    automatically from their /etc/rc script (SYS5R2) or a script
  148. X    in /etc/rc2.d (SYS5R3).  The Makefile by default installs upsd
  149. X    in the /etc directory when the install target is made.  
  150. X
  151. X
  152. X     Tue Apr 02 23:24:20 HST 1991    art@pilikia.pegasus.com        Pg. 2
  153. X
  154. X
  155. X    COMMAND LINE OPTIONS
  156. X
  157. X    Upsd runtime behavior can be configured either on the command
  158. X    line or via environment variables.  The command line options
  159. X    take precedence to the environment variable settings, and are
  160. X    as follows:
  161. X
  162. X    usage: upsd [-d tty][-c cmd][-l log][-t min]
  163. X        -d tty        pathname of UPS device
  164. X        -c cmd        pathname of shutdown command
  165. X        -l log        pathname of UPS log file
  166. X        -t min        delay time in minutes
  167. X
  168. X    The -d tty option must specify the full pathname (including the
  169. X    /dev/ prefix) to the tty device the UPS is on.
  170. X
  171. X    Example:
  172. X
  173. X    upsd -d /dev/ttyFM00
  174. X
  175. X    The -c cmd option specifies the full pathname of the command
  176. X    to be executed to shut down the system.  This command must
  177. X    be enclosed in quotes if it consists of 2 or more words.
  178. X
  179. X    Example:
  180. X
  181. X    upsd -d /dev/ttyFM00 -c "/etc/shutdown -y -g1 -i0"
  182. X
  183. X    The -l option specified the logfile upsd will write it's event
  184. X    messages to, these messages give the date and time that the UPS
  185. X    daemon started, switched to battery, switched back to online,
  186. X    executed the shutdown command, or was terminated via SIGTERM.
  187. X
  188. X    Example:
  189. X
  190. X    upsd -d /dev/ttyFM00 -c "/etc/shutdown -y -g1 -i0" -l /etc/upslog
  191. X
  192. X    Finally, the -t option specifies the number of minutes to allow
  193. X    the UPS to be on battery backup before executing the shutdown
  194. X    sequence.  This number must be between 1 and 30.  Be careful not
  195. X    to choose a value greater than the number of minutes of battery
  196. X    time your UPS supports with your current load.  A value in the
  197. X    5 to 10 minute range is probably sufficient.
  198. X
  199. X    Example:
  200. X
  201. X    upsd -d /dev/ttyFM00 -c "/etc/shutdown -y -g1 -i0" -l /etc/upslog -t 10
  202. X    
  203. X     Tue Apr 02 23:24:20 HST 1991    art@pilikia.pegasus.com        Pg. 3
  204. X
  205. X
  206. X    ENVIRONMENT VARIABLES
  207. X
  208. X    The following environment variables can be set if that interface
  209. X    is preferred to the command line options.  Note again that command
  210. X    line options override the environment variable settings.
  211. X
  212. X
  213. X    Environment    Equivalent        Default
  214. X    Variable    Command line option    Value
  215. X    UPSPORT            -p        /dev/ttyFM00
  216. X    UPSSHUT            -c        "/etc/shutdown -y -g1 -i0"
  217. X    UPSLOG            -l        /etc/upslog
  218. X    UPSTIME            -t        10
  219. X
  220. X    Note that the compiled in default values can be altered in common.h
  221. X    and the program can be recompiled.  If no command line options or
  222. X    environment variables exist, the defaults will be used.  The table
  223. X    above gives the environment variables looked for by the program and
  224. X    their command line option counterparts.  All the rules applying to
  225. X    the command line options apply to the environment variables as well.
  226. X
  227. X    If you have any comments or suggestions regarding my program,
  228. X    send email to the following address:
  229. X
  230. X    Arthur W. Neilson III
  231. X    INET: art@pilikia.pegasus.com
  232. X    UUCP: uunet!ucsd!nosc!pilikia!art
  233. X
  234. END_OF_FILE
  235. if test 3910 -ne `wc -c <'README'`; then
  236.     echo shar: \"'README'\" unpacked with wrong size!
  237. fi
  238. # end of 'README'
  239. fi
  240. if test -f 'common.h' -a "${1}" != "-c" ; then 
  241.   echo shar: Will not clobber existing file \"'common.h'\"
  242. else
  243. echo shar: Extracting \"'common.h'\" \(1885 characters\)
  244. sed "s/^X//" >'common.h' <<'END_OF_FILE'
  245. X/*
  246. X**    c o m m o n . h
  247. X**
  248. X**    common header file for UPS monitor daemon
  249. X**
  250. X**    Arthur W. Neilson III
  251. X**    art@pilikia.pegasus.com
  252. X**    Sat Mar 30 1991
  253. X*/
  254. X
  255. X#include <stdio.h>
  256. X#include <string.h>
  257. X#include <fcntl.h>
  258. X#include <time.h>
  259. X#include <sys/types.h>
  260. X#include <sys/termio.h>
  261. X#include <sys/signal.h>
  262. X#include <sys/stat.h>
  263. X
  264. X#define ERR        -1        /* error return value */
  265. X#define SH        "/bin/sh"    /* shell to exec shutdown command */
  266. X#define ROOT        "/"        /* root directory for chdir */
  267. X#define CONSOLE        "/dev/console"    /* console device */
  268. X#define SECS_PER_MIN    60        /* number of secs in a minute */
  269. X#define MAX_TIME    30        /* maximum delay time allowed */
  270. X#define SHUT_PERMS    0500        /* shutdown command permissions mask */
  271. X#define LOG_PERMS    0600        /* logfile permissions on create */
  272. X#define LOG_FLAGS    O_WRONLY | O_CREAT | O_APPEND    /* logfile open flags */
  273. X
  274. X/* default tuneable parameter values */
  275. X#define UPS_PORT    "/dev/ttyFM00"    /* UPS port device name */
  276. X#define UPS_SHUT    "/etc/shutdown -y -g0"    /* shutdown command */
  277. X#define UPS_LOG        "/etc/upslog"    /* UPS log file pathname */
  278. X#define UPS_TIME    10        /* default delay time (minutes) */
  279. X
  280. X/* environment variable names */
  281. X#define UPSPORT        "UPSPORT"
  282. X#define UPSSHUT        "UPSSHUT"
  283. X#define UPSLOG        "UPSLOG"
  284. X#define UPSTIME        "UPSTIME"
  285. X
  286. X/* UPS log messages */
  287. X#define START_MSG    "UPS daemon started"
  288. X#define OPEN_MSG    "Error opening UPS port"
  289. X#define BATTERY_MSG    "UPS switch to battery backup"
  290. X#define ONLINE_MSG    "UPS switch to online power"
  291. X#define SHUTDOWN_MSG    "Shutdown command executed"
  292. X#define TERM_MSG    "Caught termination signal"
  293. X
  294. X/* common globals */
  295. Xextern char   *ups_port;        /* UPS device name */
  296. Xextern char   *ups_shut;        /* system shutdown command */
  297. Xextern char   *ups_log;            /* UPS log file name */
  298. Xextern int     ups_time;        /* delay time before shutdown */
  299. Xextern int     ups_fd;            /* UPS port descriptor */
  300. Xextern int     log_fd;            /* log file descriptor */
  301. END_OF_FILE
  302. if test 1885 -ne `wc -c <'common.h'`; then
  303.     echo shar: \"'common.h'\" unpacked with wrong size!
  304. fi
  305. # end of 'common.h'
  306. fi
  307. if test -f 'funcs.c' -a "${1}" != "-c" ; then 
  308.   echo shar: Will not clobber existing file \"'funcs.c'\"
  309. else
  310. echo shar: Extracting \"'funcs.c'\" \(4629 characters\)
  311. sed "s/^X//" >'funcs.c' <<'END_OF_FILE'
  312. X/*
  313. X**    f u n c s . c
  314. X**
  315. X**    functions for UPS monitor daemon
  316. X**
  317. X**    Arthur W. Neilson III
  318. X**    art@pilikia.pegasus.com
  319. X**    Sat Mar 30 1991
  320. X*/
  321. X
  322. X#include "common.h"
  323. X
  324. X/*
  325. X**    g e t v a r s
  326. X**
  327. X**    retrieve environment variables
  328. X*/
  329. Xvoid
  330. Xgetvars()
  331. X{
  332. X    char   *s, *getenv();
  333. X
  334. X    if ((s = getenv(UPSPORT)) != NULL)
  335. X        ups_port = s;
  336. X    if ((s = getenv(UPSSHUT)) != NULL)
  337. X        ups_shut = s;
  338. X    if ((s = getenv(UPSLOG)) != NULL)
  339. X        ups_log = s;
  340. X    if ((s = getenv(UPSTIME)) != NULL)
  341. X        ups_time = atoi(s) * SECS_PER_MIN;
  342. X}
  343. X
  344. X/*
  345. X**    g e t o p t i o n s
  346. X**
  347. X**    retrieve and process command line options
  348. X*/
  349. Xvoid
  350. Xgetoptions(ac, av)
  351. Xint     ac;
  352. Xchar   *av[];
  353. X{
  354. X    int     c;
  355. X
  356. X    void    usage();
  357. X
  358. X    extern char *optarg;
  359. X    extern int optind, opterr;
  360. X
  361. X    /* parse the command line */
  362. X    while ((c = getopt(ac, av, "d:c:l:t:")) != EOF)
  363. X        switch (c) {
  364. X        case 'd':    /* device option */
  365. X            ups_port = optarg;
  366. X            break;
  367. X        case 'c':    /* command option */
  368. X            ups_shut = optarg;
  369. X            break;
  370. X        case 'l':    /* logfile option */
  371. X            ups_log = optarg;
  372. X            break;
  373. X        case 't':    /* time option */
  374. X            ups_time = atoi(optarg) * SECS_PER_MIN;
  375. X            break;
  376. X        case '\?':    /* illegal option */
  377. X            usage(av[0]);
  378. X            exit(1);
  379. X        }
  380. X}
  381. X
  382. X/*
  383. X**    c h k o p t i o n s
  384. X**
  385. X**    check runtime options
  386. X*/
  387. Xvoid
  388. Xchkoptions()
  389. X{
  390. X    struct stat st;
  391. X    char   *p, buf[64];
  392. X
  393. X    /* UPS port must exist */
  394. X    if (stat(ups_port, &st) == ERR) {
  395. X        perror(ups_port);
  396. X        exit(1);
  397. X    }
  398. X    /* and must be character special */
  399. X    if ((st.st_mode & S_IFMT) != S_IFCHR) {
  400. X        fprintf(stderr, "%s not character special\n", ups_port);
  401. X        exit(1);
  402. X    }
  403. X    /* get command name out of shutdown command */
  404. X    strcpy(buf, ups_shut);
  405. X    if ((p = strtok(buf, " ")) == NULL)
  406. X        p = buf;
  407. X
  408. X    /* shutdown command must exist */
  409. X    if (stat(p, &st) == ERR) {
  410. X        perror(ups_shut);
  411. X        exit(1);
  412. X    }
  413. X    /* and must be readable/executable by owner */
  414. X    if (!(st.st_mode & SHUT_PERMS)) {
  415. X        fprintf(stderr, "%s must be readable/executable by owner\n", ups_port);
  416. X        exit(1);
  417. X    }
  418. X    /* delay time must be > 0 and <= MAX_TIME */
  419. X    if (ups_time < 1 || ups_time > MAX_TIME) {
  420. X        fprintf(stderr, "time must be between 1 and %d\n", MAX_TIME);
  421. X        exit(1);
  422. X    }
  423. X}
  424. X
  425. X/*
  426. X**    m k d a e m o n
  427. X**
  428. X**    create daemon process
  429. X*/
  430. Xvoid
  431. Xmkdaemon()
  432. X{
  433. X    char    c;
  434. X
  435. X    void    sigcatch();
  436. X    void    writelog();
  437. X    void    shutdown();
  438. X
  439. X    if (!fork()) {
  440. X
  441. X        /* close standard files */
  442. X        close(0);    /* stdin */
  443. X        close(1);    /* stdout */
  444. X        close(2);    /* stderr */
  445. X
  446. X        setpgrp();    /* disassociate from terminal */
  447. X
  448. X        /* ignore interrupts */
  449. X        signal(SIGHUP, SIG_IGN);
  450. X        signal(SIGINT, SIG_IGN);
  451. X        signal(SIGQUIT, SIG_IGN);
  452. X
  453. X        /* catch termination signal */
  454. X        signal(SIGTERM, sigcatch);
  455. X
  456. X        /* and shutdown on alarm */
  457. X        signal(SIGALRM, shutdown);
  458. X
  459. X        /* open log file for append */
  460. X        if ((log_fd = open(ups_log, LOG_FLAGS, LOG_PERMS)) == ERR)
  461. X            exit(1);
  462. X
  463. X        writelog(START_MSG);
  464. X
  465. X        /* open blocks on UPS switch to battery */
  466. X        if ((ups_fd = open(ups_port, O_RDWR)) == ERR) {
  467. X            writelog(OPEN_MSG);
  468. X            exit(1);
  469. X        }
  470. X        writelog(BATTERY_MSG);
  471. X
  472. X        alarm(ups_time);/* set the alarm clock */
  473. X
  474. X        /* read blocks on UPS switch to online */
  475. X        if (read(ups_fd, &c, 1) == ERR)
  476. X            exit(1);
  477. X
  478. X        writelog(ONLINE_MSG);
  479. X
  480. X        close(log_fd);
  481. X        close(ups_fd);
  482. X
  483. X        mkdaemon();
  484. X    }
  485. X}
  486. X
  487. X/*
  488. X**    s i g c a t c h
  489. X**
  490. X**    catch termination signal
  491. X*/
  492. Xvoid
  493. Xsigcatch()
  494. X{
  495. X    writelog(TERM_MSG);
  496. X    close(log_fd);
  497. X    close(ups_fd);
  498. X    exit(1);
  499. X}
  500. X
  501. X/*
  502. X**    w r i t e l o g
  503. X**
  504. X**    write message to the UPS log file
  505. X*/
  506. Xvoid
  507. Xwritelog(msg)
  508. Xchar   *msg;
  509. X{
  510. X    time_t  ticks;
  511. X    char   *p, *ct;
  512. X    char    msg_buf[80];
  513. X
  514. X    time(&ticks);
  515. X    ct = ctime(&ticks);
  516. X
  517. X    /* find newline in buffer */
  518. X    if ((p = strrchr(ct, '\n')) != NULL)
  519. X        *p = NULL;    /* and zap it */
  520. X
  521. X    sprintf(msg_buf, "%s -- %s\n", ct, msg);
  522. X    write(log_fd, msg_buf, strlen(msg_buf));
  523. X}
  524. X
  525. X/*
  526. X**    s h u t d o w n
  527. X**
  528. X**    shutdown the system
  529. X*/
  530. Xvoid
  531. Xshutdown()
  532. X{
  533. X    void    attach();
  534. X
  535. X    writelog(SHUTDOWN_MSG);
  536. X
  537. X    close(log_fd);
  538. X    close(ups_fd);
  539. X
  540. X    attach(CONSOLE);
  541. X
  542. X    chdir(ROOT);
  543. X
  544. X    /* execute shutdown command */
  545. X    execlp(SH, SH, "-c", ups_shut, NULL);
  546. X}
  547. X
  548. X/*
  549. X**    a t t a c h
  550. X**
  551. X**    attach standard i/o to a device
  552. X*/
  553. Xvoid
  554. Xattach(dev)
  555. Xchar   *dev;
  556. X{
  557. X    int     fd;
  558. X
  559. X    /* close standard files */
  560. X    close(0);        /* stdin */
  561. X    close(1);        /* stdout */
  562. X    close(2);        /* stderr */
  563. X
  564. X    /* attach stdin to named device */
  565. X    if ((fd = open(dev, O_RDWR)) == ERR)
  566. X        exit(1);
  567. X    dup(fd);        /* and stdout */
  568. X    dup(fd);        /* and stderr */
  569. X}
  570. X
  571. X/*
  572. X**    u s a g e
  573. X**
  574. X**    display program usage
  575. X*/
  576. Xvoid
  577. Xusage(s)
  578. Xchar   *s;
  579. X{
  580. X    fprintf(stderr, "usage: %s [-d tty][-c cmd][-l log][-t min]\n", s);
  581. X    fprintf(stderr, "\t-d tty\t\tpathname of UPS device\n");
  582. X    fprintf(stderr, "\t-c cmd\t\tpathname of shutdown command\n");
  583. X    fprintf(stderr, "\t-l log\t\tpathname of UPS log file\n");
  584. X    fprintf(stderr, "\t-t min\t\tdelay time in minutes\n");
  585. X}
  586. END_OF_FILE
  587. if test 4629 -ne `wc -c <'funcs.c'`; then
  588.     echo shar: \"'funcs.c'\" unpacked with wrong size!
  589. fi
  590. # end of 'funcs.c'
  591. fi
  592. if test -f 'main.c' -a "${1}" != "-c" ; then 
  593.   echo shar: Will not clobber existing file \"'main.c'\"
  594. else
  595. echo shar: Extracting \"'main.c'\" \(692 characters\)
  596. sed "s/^X//" >'main.c' <<'END_OF_FILE'
  597. X/*
  598. X**    m a i n . c
  599. X**
  600. X**    main program for UPS monitor daemon
  601. X**
  602. X**    Arthur W. Neilson III
  603. X**    art@pilikia.pegasus.com
  604. X**    Sat Mar 30 1991
  605. X*/
  606. X
  607. X#include "common.h"
  608. X
  609. X/* default tuneables */
  610. Xchar   *ups_port = UPS_PORT;
  611. Xchar   *ups_shut = UPS_SHUT;
  612. Xchar   *ups_log = UPS_LOG;
  613. Xint     ups_time = UPS_TIME;
  614. X
  615. X/* global descriptors */
  616. Xint     ups_fd;
  617. Xint     log_fd;
  618. X
  619. Xmain(argc, argv)
  620. Xint     argc;
  621. Xchar   *argv[];
  622. X{
  623. X    void    getvars();
  624. X    void    getoptions();
  625. X    void    chkoptions();
  626. X    void    mkdaemon();
  627. X
  628. X    getvars();        /* retrieve environment vars */
  629. X    getoptions(argc, argv);    /* process command line options */
  630. X    chkoptions();        /* validate command line options */
  631. X    mkdaemon();        /* fork daemon process */
  632. X}
  633. END_OF_FILE
  634. if test 692 -ne `wc -c <'main.c'`; then
  635.     echo shar: \"'main.c'\" unpacked with wrong size!
  636. fi
  637. # end of 'main.c'
  638. fi
  639. if test -f 'ups' -a "${1}" != "-c" ; then 
  640.   echo shar: Will not clobber existing file \"'ups'\"
  641. else
  642. echo shar: Extracting \"'ups'\" \(296 characters\)
  643. sed "s/^X//" >'ups' <<'END_OF_FILE'
  644. X#ident    "@(#)ups    1.0 - 91/03/30"
  645. X#    UPS monitor daemon
  646. X
  647. X# configure UPS daemon runtime
  648. Xexport UPSPORT; UPSPORT=/dev/ttyFM00
  649. Xexport UPSSHUT; UPSSHUT="/etc/shutdown -y -i0"
  650. Xexport UPSLOG;  UPSLOG=/etc/upslog
  651. Xexport UPSTIME; UPSTIME=10
  652. X
  653. Xset `who -r`
  654. Xif [ $9 = "S" -a -x /etc/upsd ]
  655. Xthen
  656. X    /etc/upsd
  657. Xfi
  658. END_OF_FILE
  659. if test 296 -ne `wc -c <'ups'`; then
  660.     echo shar: \"'ups'\" unpacked with wrong size!
  661. fi
  662. chmod +x 'ups'
  663. # end of 'ups'
  664. fi
  665. echo shar: End of archive 1 \(of 1\).
  666. cp /dev/null ark1isdone
  667. MISSING=""
  668. for I in 1 ; do
  669.     if test ! -f ark${I}isdone ; then
  670.     MISSING="${MISSING} ${I}"
  671.     fi
  672. done
  673. if test "${MISSING}" = "" ; then
  674.     echo You have the archive.
  675.     rm -f ark[1-9]isdone
  676. else
  677.     echo You still need to unpack the following archives:
  678.     echo "        " ${MISSING}
  679. fi
  680. ##  End of shell archive.
  681. exit 0
  682. -----8<----- cut here -----8<----- cut here -----8<----- cut here -----8<-----
  683.  
  684. -- 
  685. Arthur W. Neilson III        | INET: art@pilikia.pegasus.com
  686. Bank of Hawaii Tech Support    | UUCP: uunet!ucsd!nosc!pilikia!art
  687.  
  688. exit 0 # Just in case...
  689. -- 
  690. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  691. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  692. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  693. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  694.